package o;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;

public final class fjy<TResult> extends fjo<TResult> {
    private List<fjs<TResult>> ʽ = new ArrayList();
    private TResult ˊ;
    private final Object ˋ = new Object();
    private Exception ˎ;
    private boolean ˏ;
    private volatile boolean ॱ;

    private void ʽ() {
        synchronized (this.ˋ) {
            for (fjs ॱ : this.ʽ) {
                try {
                    ॱ.ॱ(this);
                } catch (RuntimeException e) {
                    throw e;
                } catch (Throwable e2) {
                    throw new RuntimeException(e2);
                }
            }
            this.ʽ = null;
        }
    }

    private fjo<TResult> ˎ(fjs<TResult> o_fjs_TResult) {
        synchronized (this.ˋ) {
            boolean ˏ = ˏ();
            if (!ˏ) {
                this.ʽ.add(o_fjs_TResult);
            }
        }
        if (ˏ) {
            o_fjs_TResult.ॱ(this);
        }
        return this;
    }

    public final boolean ˊ() {
        boolean z;
        synchronized (this.ˋ) {
            z = this.ˏ && !ˎ() && this.ˎ == null;
        }
        return z;
    }

    public final Exception ˋ() {
        Exception exception;
        synchronized (this.ˋ) {
            exception = this.ˎ;
        }
        return exception;
    }

    public final fjo<TResult> ˋ(Executor executor, fjp<TResult> o_fjp_TResult) {
        return ˎ(new fka(executor, o_fjp_TResult));
    }

    public final fjo<TResult> ˋ(Executor executor, fjq<TResult> o_fjq_TResult) {
        return ˎ(new fjv(executor, o_fjq_TResult));
    }

    public final fjo<TResult> ˋ(fjr o_fjr) {
        return ॱ(fjt.ˋ(), o_fjr);
    }

    public final void ˋ(Exception exception) {
        synchronized (this.ˋ) {
            if (this.ˏ) {
                return;
            }
            this.ˏ = true;
            this.ˎ = exception;
            this.ˋ.notifyAll();
            ʽ();
        }
    }

    public final boolean ˎ() {
        return this.ॱ;
    }

    public final fjo<TResult> ˏ(fjp<TResult> o_fjp_TResult) {
        return ˋ(fjt.ˋ(), (fjp) o_fjp_TResult);
    }

    public final fjo<TResult> ˏ(fjq<TResult> o_fjq_TResult) {
        return ˋ(fjt.ˋ(), (fjq) o_fjq_TResult);
    }

    public final boolean ˏ() {
        boolean z;
        synchronized (this.ˋ) {
            z = this.ˏ;
        }
        return z;
    }

    public final TResult ॱ() {
        TResult tResult;
        synchronized (this.ˋ) {
            if (this.ˎ != null) {
                throw new RuntimeException(this.ˎ);
            }
            tResult = this.ˊ;
        }
        return tResult;
    }

    public final fjo<TResult> ॱ(Executor executor, fjr o_fjr) {
        return ˎ(new fkb(executor, o_fjr));
    }

    public final void ॱ(TResult tResult) {
        synchronized (this.ˋ) {
            if (this.ˏ) {
                return;
            }
            this.ˏ = true;
            this.ˊ = tResult;
            this.ˋ.notifyAll();
            ʽ();
        }
    }
}
